Skip to content

Derive species presence cols from CSV header#107

Merged
NewGraphEnvironment merged 1 commit intomainfrom
106-spp-cols-dynamic
May 3, 2026
Merged

Derive species presence cols from CSV header#107
NewGraphEnvironment merged 1 commit intomainfrom
106-spp-cols-dynamic

Conversation

@NewGraphEnvironment
Copy link
Copy Markdown
Owner

Summary

  • Drops the hardcoded spp_cols <- c("bt", "ch", ...) vector in R/lnk_pipeline_species.R and R/lnk_pipeline_break.R. Both call sites now share .lnk_wsg_species_present(row) (in R/utils.R) which derives the presence-column list from the CSV header.
  • Result: adding a new species column to wsg_species_presence.csv propagates to every callsite without a code edit.
  • Adds ko column to both bundles' wsg_species_presence.csv with sentinel t for PARS, KOTL, NATR, CARP — interim until upstream bcfishpass.wsg_species_presence ships the authoritative coverage (Add ko (Kokanee) column to wsg_species_presence.csv bcfishpass#12).
  • Adds GR + KO species rows to default/parameters_fresh.csv (already present in default/dimensions.csv and rules.yaml).

Why

R/lnk_pipeline_species.R:63-64 and R/lnk_pipeline_break.R:167-168 were a footgun: the CSV could carry a gr column populated t for many WSGs, but lnk_pipeline_species() would silently drop GR for every AOI because the hardcoded vector didn't include it. Surfaced when adding GR + KO to enable Kokanee / Arctic Grayling habitat classification on the default bundle.

Test plan

Out of scope

Relates to NewGraphEnvironment/sred-2025-2026#24

🤖 Generated with Claude Code

`R/lnk_pipeline_species.R` and `R/lnk_pipeline_break.R` hardcoded the
species-presence column list to 11 codes (bt, ch, cm, co, ct, dv, pk,
rb, sk, st, wct). Adding a new species to dimensions.csv +
parameters_fresh.csv was silently dropped at the column-list step
because the new column was never read.

- Extract `.lnk_wsg_species_present(row)` to R/utils.R. Treats every
  column except `watershed_group_code` and `notes` as a presence flag.
  Both call sites use the helper.
- Add ko (Kokanee) column to wsg_species_presence.csv in both bundles
  with `t` for PARS, KOTL, NATR, CARP. Sentinel values for testing
  end-to-end KO flow — actual presence-by-WSG belongs upstream in
  bcfp's wsg_species_presence.csv (filed at
  NewGraphEnvironment/bcfishpass#12). Auto-sync workflow will replace
  these with the authoritative source once that lands.
- Add GR + KO species rows to default/parameters_fresh.csv (already
  present in default/dimensions.csv and rules.yaml).
- New tests: lnk_pipeline_species picks up newly-added GR + KO columns
  when populated, and ignores the `notes` column.

Relates to NewGraphEnvironment/sred-2025-2026#24

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@NewGraphEnvironment NewGraphEnvironment merged commit 3232077 into main May 3, 2026
1 check passed
@NewGraphEnvironment NewGraphEnvironment deleted the 106-spp-cols-dynamic branch May 3, 2026 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant